Imports NUnit.Framework
Imports ValidationFramework

Namespace PropertyValidationManagerExamples
    Public Class ExternalExample
#Region "Example"
        Public Class Person
            ' Properties
            <RequiredIntRule()> _
            Public Property Age() As Integer
                Get
                    Return _age
                End Get
                Set(ByVal value As Integer)
                    _age = value
                End Set
            End Property


            ' Fields
            Private _age As Integer
        End Class



        <TestFixture()> _
        Public Class ExampleUsage
            ' Methods
            <Test()> _
            Public Sub Run()
                Dim person As New Person
                Dim propertyValidationManager As New PropertyValidationManager(person)
                'Could have called propertyValidationManager.Validate() here to validate all 
                ' properties
                propertyValidationManager.Validate("Age")
                Assert.IsFalse(propertyValidationManager.IsValid)
                person.Age = 99
                ' Could have called propertyValidationManager.Validate() here to validate all 
                ' properties()
                propertyValidationManager.Validate("Age")
                Assert.IsTrue(propertyValidationManager.IsValid)
            End Sub

        End Class
#End Region
    End Class
End Namespace